

#---Portmann & Stojanovic 2017: Electoral discrimination against immigrant-origin candidates---#

#load("PrefVotes")

#-------------------- ESTIMATE MODELS (HIERARCHICAL BETA REGRESSION, LOGIT LINK)

model1 <- glmmadmb(crossoff_pct ~ nonswissnames + (~1|list_id), data=d, family="Beta")

model2 <- glmmadmb(crossoff_pct ~ nonswissnames + incumbent + c_relposition_rc + precumulated + 
                     sex_d + age_c3 + CodeBerufK3 + num_cand + party_c3 + commune
                   (~1|list_id), data=d, family="Beta", admb.opts=admbControl(shess=FALSE,noinit=FALSE))

model3 <- glmmadmb(crossoff_pct ~ nonswissnames + incumbent + c_relposition_rc + precumulated + 
                     sex_d + age_c3 + CodeBerufK3 + num_cand + party_c3 + nonswissnames:party_c3 + commune + 
                     (~1|list_id), data=d, family="Beta", admb.opts=admbControl(shess=FALSE,noinit=FALSE))

#-------------------- REGRESSION TABLE

htmlreg(list(model1, model2, model3), custom.model.names = c("Model 1", "Model 2", "Model 3"),
        caption = "Negative preference votes vs. non-Swiss names",
        label = "tab:5",
        stars = c(0.05, 0.01, 0.001),
        dcolumn = TRUE,
        booktabs = TRUE,
        use.packages = FALSE,
        single.row = TRUE,
        include.adjrs = FALSE,
        include.bic = FALSE, file = "Table5.doc")
